﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using System.Net;
using System.Text;

namespace VQWEB.administrator.configs
{
    public partial class configs : System.Web.UI.Page    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            //SendMail(); 
            
        }

        private void SendMail()
        {
            try
            {
                //MailAddress
                MailAddressCollection collection = new MailAddressCollection();
                collection.Add("quannh85@gmail.com");
                collection.Add("lantinhql@yahoo.com");
                //collection.Add("xuantruongclub@yahoo.com");
                //collection.Add("caothao.1984@gmail.com");
                //collection.Add("toannt263@gmail.com");
                //collection.Add("truongdx79@gmail.com");
                //collection.Add("sanhanoi1@gmail.com");

                SmtpClient SmtpClient = new SmtpClient();
                SmtpClient.Host = "smtp.gmail.com";
                SmtpClient.Port = 587;
                SmtpClient.EnableSsl = true;
                //SmtpClient.Timeout = 10000;
                SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                SmtpClient.UseDefaultCredentials = false;
                SmtpClient.Credentials = new NetworkCredential("truongdx79@gmail.com", "minhvy2007");


                MailMessage MailMessage = new MailMessage();
                //MailMessage.To.Add("xuantruongclub@yahoo.com");
                foreach (MailAddress item in collection)
                {
                    MailMessage.To.Add(item);
                }
                MailMessage.From = new MailAddress("truongdx79@gmail.com");
                MailMessage.IsBodyHtml = true;
                MailMessage.BodyEncoding = Encoding.UTF8;
                MailMessage.SubjectEncoding = Encoding.UTF8;
                MailMessage.Subject = "Xin chào, xuân trường thử send email qua software hỗ trợ tiếng việt lần cuối";
                MailMessage.Body = "<b>Xuân Trường:</b> Đang thử send nội dung tiếng việt hỗ trợ Unicode <font color=\"red\">Màu đỏ</font>";

                SmtpClient.Send(MailMessage);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                throw;
            }
        }
    }
}